<template>
  <div class="table" id="table">
    <div class="print">
      <el-button type="primary" @click="printFn">打印</el-button>
    </div>
    <div class="container" id="container">
      <h2 style="margin: 0;">ICU危重症患者APACHE II评分系统表 </h2>
      <div class="baseInfo">

        <div>姓名：{{ patientInfo?.name }}</div>
        <div>性别：{{ patientInfo?.sex }}</div>
        <div>年龄：{{ patientInfo?.age }}</div>
        <div>床号：{{ patientInfo?.bedName }}</div>
        <div>住院号：{{ patientInfo?.admissionNumber }}</div>
      </div>
      <table cellspacing="0" class="bordered-table">
        <tbody>
          <!-- A.年龄 -->
          <tr>
            <td colspan="1">A.年龄</td>
            <td colspan="5">
              <div class="dflex">
                <div v-for="(item, index) in ageList" :key="index" class="age">
                  <div style="margin-right: 10px;">{{ item.value }}</div>
                  <el-checkbox :label=item.score @click="countAscoreFn(item, 'A')" v-model="item.checked" />
                </div>
              </div>
            </td>
            <td colspan="1">A计分：{{ Allscore.Ascore }}</td>
          </tr>
        </tbody>
      </table>
      <!-- B.慢性健康状况 -->
      <table cellspacing="0" class="bordered-table">
        <tbody>
          <tr>
            <td colspan="1">B.慢性健康状况 </td>
            <td colspan="5">
              <div class="dflex">
                <div v-for="(item, index) in healthList" :key="index" class="age">
                  <div style="margin-right: 10px;">{{ item.value }}</div>
                  <el-checkbox :label=item.score @click="countAscoreFn(item, 'B')" v-model="item.checked" />
                </div>
              </div>
            </td>
            <td colspan="1">B.计分：{{ Allscore.Bscore }}</td>
          </tr>
        </tbody>
      </table>
      <!-- C.GCS评分 -->
      <table cellspacing="0" class="bordered-table">
        <tbody>
          <tr>
            <td style="width: 160px;">{{ GCSscoreList.row.name }}</td>
            <td v-for="(item, idnex) in GCSscoreList.row.scoreList" :key="idnex">
              {{ item }}
            </td>
          </tr>
          <tr v-for="(item, index) in GCSscoreList.data" :key="index">
            <td>
              {{ item.name }}
            </td>
            <td v-for="(child, childIndex) in item.intervalList" :key="childIndex">
              <el-checkbox :label="child.value" v-if="child.value !== ''"
                @click="handleCheckChange(child, childIndex, item.intervalList)" v-model="child.checked"></el-checkbox>
            </td>
          </tr>
          <tr>
            <td colspan="3">GCS积分=1+2+3</td>
            <td colspan="2">C. 积分=15-GCS</td>
            <td colspan="2">C记分：{{ CStore }}</td>
          </tr>
        </tbody>
      </table>
      <!-- D. 急性生理指标 -->
      <table cellspacing="0" class="bordered-table">
        <thead>
          <tr>
            <td rowspan="2" colspan="1">
              {{ physiologyList.row.name }}
            </td>
            <td colspan="9">
              <div class="td-div">
                {{ physiologyList.row.scope }}
              </div>
            </td>
          </tr>
          <tr>
            <td v-for="(item, idnex) in physiologyList.row.scoreList" :key="idnex">
              <div>
                {{ item }}
              </div>
            </td>
          </tr>
        </thead>
        <!-- 评分数据 -->
        <tbody>
          <tr v-for="(item, index) in physiologyList.data" :key="index">
            <td>
              {{ item.name }}
            </td>
            <td v-for="(child, childIndex) in item.intervalList" :key="childIndex">
              <el-checkbox :label="child.value" v-if="child.value !== ''"
                @click="handleCheckChange(child, childIndex, item.intervalList)" v-model="child.checked"></el-checkbox>
            </td>
          </tr>
        </tbody>
        <tfoot>
          <tr>
            <td colspan="10">
              D计分：{{ DStore }}
            </td>
          </tr>
        </tfoot>
      </table>
      <div class="footer">
        <div class="fraction_info">
          <div>APACHE II 总积分=A+B+C+D</div>
          <div>评分时间：入ICU后<el-input placeholder="请输入" size="small" v-model="timeVlue"
              style="width: 60px;margin:0 5px;"></el-input> 小时</div>
          <div>APACHE II 总积分：{{ total }} 分</div>

        </div>
        <div class="graders">
          <el-checkbox :label="item.score" @click="discrepancyChange(index)" v-model="item.checked"
            v-for="(item, index)  in discrepancy" :key="index"></el-checkbox>
          <div style="margin-left:40px">
            评分人:
          </div>
        </div>
        <!-- <div class="describe">
          <div class="describe_title">
            说明：
          </div>
          <div class="describe_content">
            <div v-for="(item, index) in describeList" :key="index">
              {{ item.name }}
            </div>
          </div>
        </div> -->

      </div>
    </div>
    <div class="operate">
      <div @click="clearFn" style="margin-right: 40px;">
        <el-button>清空</el-button>
      </div>

      <div @click="handleSubmit">
        <el-button type="primary">保存</el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { watchEffect } from "vue";
import { reactive, toRefs, computed, onMounted } from "vue";
import { getPatientInfoAPI, saveDocPatientInfoAPI, getDocDataAPI } from "@/api/book.js";
import { useRoute } from 'vue-router';
import printJS from "print-js";
import html2canvas from "html2canvas";
const state = reactive({
  ageList: [{
    score: '0', //这里如果 没自定义的话 就是重复
    value: '<=44',
    checked: false
  },
  {
    score: '2', //这里如果 没自定义的话 就是重复
    value: '45-54',
    checked: false
  }, {
    score: '3', //这里如果 没自定义的话 就是重复
    value: '55-64',
    checked: false
  }
    , {
    score: '5', //这里如果 没自定义的话 就是重复
    value: '65-74',
    checked: false
  }, {
    score: '6', //这里如果 没自定义的话 就是重复
    value: '>=75',
    checked: false
  }],
  healthList: [{
    score: '2', //这里如果 没自定义的话 就是重复
    value: '有慢性病，探期手木后',
    checked: false
  },
  {
    score: '5', //这里如果 没自定义的话 就是重复
    value: '有慢性病，非手木或急诊手术后',
    checked: false
  },
  {
    score: '3', //这里如果 没自定义的话 就是重复
    value: '无慢性疾病',
    checked: false
  }],
  physiologyList: {
    row: {
      name: 'D. 急性生理指标',
      scope: '分',
      scoreList: ['+4', '+3', '+2', '+1', '0', '+1', '+2', '+3', '+4'], // 选中的分数
    },
    data: [
      {
        name: '1.体温（ 腋下°C ）',
        type: 'bodyTemperature',
        checkIndex: null, // 保存选中的值 或者下标
        intervalList: [
          {
            score: '4', //这里如果 没自定义的话 就是重复
            value: '>=41',
            checked: false
          },
          {
            score: '3',
            value: '39-40.9',
            checked: false
          },
          {
            score: '2',
            value: '',
            checked: false
          },
          {
            score: '1',
            value: '38.5-38.9',
            checked: false
          },
          {
            score: '0',
            value: '36-38.4',
            checked: false
          },
          {
            score: '1',
            value: '34-35.9',
            checked: false
          },
          {
            score: '2',
            value: '32-33.9',
            checked: false
          },
          {
            score: '3',
            value: '30-31.9',
            checked: false
          },
          {
            score: '4',
            value: '<=29.9',
            checked: false
          },
        ]
      },
      {
        name: '2.平均血压（mmHg）',
        type: 'bloodPressure',

        checkIndex: null, // 保存选中的值 或者下标
        intervalList: [
          {
            score: '4',
            value: '>=160',
            checked: false

          },
          {
            score: '3',
            value: '130-159',
            checked: false

          },
          {
            score: '2',
            value: '110-129',
            checked: false

          },
          {
            score: '1',
            value: '',
            checked: false

          },
          {
            score: '0',
            value: '70-109',
            checked: false

          },
          {
            score: '1',
            value: '',
            checked: false

          },
          {
            score: '2',
            value: '50-69',
            checked: false

          },
          {
            score: '3',
            value: '',
            checked: false

          },
          {
            score: '4',
            value: '<=49',
            checked: false

          },
        ]
      },
      {
        name: '3.心率(次/分)',
        type: 'heartRate',
        intervalList: [
          {
            score: '4',
            value: '>=180',
            checked: false

          },
          {
            score: '3',
            value: '140-179',
            checked: false

          },
          {
            score: '2',
            value: '110-129',
            checked: false

          },
          {
            score: '1',
            value: '',
            checked: false

          },
          {
            score: '0',
            value: '70-109',
            checked: false

          },
          {
            score: '1',
            value: '',
            checked: false

          },
          {
            score: '2',
            value: '50-69',
            checked: false

          },
          {
            score: '3',
            value: '40-49',
            checked: false

          },
          {
            score: '4',
            value: '<=39',
            checked: false

          },
        ]
      },
      {
        name: '4.呼吸频率(次/分)',
        type: 'respiratoryRate',
        intervalList: [
          {
            score: '4',
            value: '>=50',
            checked: false
          },
          {
            score: '3',
            value: '35-49',
            checked: false
          },
          {
            score: '2',
            value: '',
            checked: false
          },
          {
            score: '1',
            value: '25-34',
            checked: false
          },
          {
            score: '0',
            value: '12-24',
            checked: false
          },
          {
            score: '1',
            value: '10-11',
            checked: false
          },
          {
            score: '2',
            value: '6-9',
            checked: false
          },
          {
            score: '3',
            value: '',
            checked: false
          },
          {
            score: '4',
            value: '<=5',
            checked: false
          },
        ]
      },
      {
        name: '5.PaO2（mmHg）（FiO2<50%）A-aDO2(HO2>50%)',
        type: 'PaO',
        intervalList: [
          {
            score: '4',
            value: '500',
            checked: false

          },
          {
            score: '3',
            value: '350-499',
            checked: false

          },
          {
            score: '2',
            value: '200-349',
            checked: false

          },
          {
            score: '1',
            value: '',
            checked: false

          },
          {
            score: '0',
            value: '>70  <200',
            checked: false

          },
          {
            score: '1',
            value: '61-70',
            checked: false

          },
          {
            score: '2',
            value: '',
            checked: false

          },
          {
            score: '3',
            value: '55-60',
            checked: false

          },
          {
            score: '4',
            value: '<55',
            checked: false

          },
        ]
      }
      ,
      {
        name: '6.动脉血PH或血清HCO3（mmol/L）（无血气时用）',
        type: 'arterialBlood',
        intervalList: [
          {
            score: '4',
            value: '>=7.7 >=52',
            checked: false

          },
          {
            score: '3',
            value: '7.6-7.69 41-51.9',
            checked: false

          },
          {
            score: '2',
            value: '',
            checked: false

          },
          {
            score: '1',
            value: '7.5-7.59 32-40.9',
            checked: false

          },
          {
            score: '0',
            value: '7.33-7.49 23-31.9',
            checked: false

          },
          {
            score: '1',
            value: '',
            checked: false

          },
          {
            score: '2',
            value: '7.25-7.32 18-21.9',
            checked: false

          },
          {
            score: '3',
            value: '7.15-7.24 15-17.9',
            checked: false

          },
          {
            score: '4',
            value: '<7.15 <15',
            checked: false

          },
        ]
      }
      ,
      {
        name: '7.血清Na（mmol/L）',
        type: 'serumNa',
        intervalList: [
          {
            score: '4',
            value: '>=180',
            checked: false

          },
          {
            score: '3',
            value: '160-179',
            checked: false

          },
          {
            score: '2',
            value: '155-159',
            checked: false

          },
          {
            score: '1',
            value: '150-154',
            checked: false

          },
          {
            score: '0',
            value: '130-149',
            checked: false

          },
          {
            score: '1',
            value: '',
            checked: false

          },
          {
            score: '2',
            value: '120-129',
            checked: false

          },
          {
            score: '3',
            value: '111-119',
            checked: false

          },
          {
            score: '4',
            value: '<=110',
            checked: false

          },
        ]
      }
      ,
      {
        name: '8.血清K（mmol/L）',
        type: 'serumK',
        checkIndex: null, // 保存选中的值 或者下标
        intervalList: [
          {
            score: '4',
            value: '>=7',
            checked: false

          },
          {
            score: '3',
            value: '6-6.9',
            checked: false

          },
          {
            score: '2',
            value: '',
            checked: false

          },
          {
            score: '1',
            value: '5.5-5.9',
            checked: false

          },
          {
            score: '0',
            value: '3.5-5.4',
            checked: false

          },
          {
            score: '1',
            value: '3-3.4',
            checked: false

          },
          {
            score: '2',
            value: '2.5-2.9',
            checked: false

          },
          {
            score: '3',
            value: '',
            checked: false
          },
          {
            score: '4',
            value: '<=12.5',
            checked: false
          },
        ]
      },
      {
        name: '9.血清肌酐（mmol/L）',
        type: 'creatinine',
        intervalList: [
          {
            score: '4',
            value: '>=305',
            checked: false
          },
          {
            score: '3',
            value: '172-304',
            checked: false
          },
          {
            score: '2',
            value: '128-171',
            checked: false
          },
          {
            score: '1',
            value: '',
            checked: false
          },
          {
            score: '0',
            value: '53-127',
            checked: false
          },
          {
            score: '1',
            value: '',
            checked: false
          },
          {
            score: '2',
            value: '<53',
            checked: false
          },
          {
            score: '3',
            value: '',
            checked: false
          },
          {
            score: '4',
            value: '',
            checked: false
          },
        ]
      }
      ,
      {
        name: '10.血球压积（%）',
        type: 'bloodCell',
        intervalList: [
          {
            score: '4',
            value: '>=60',
            checked: false
          },
          {
            score: '3',
            value: '',
            checked: false
          },
          {
            score: '2',
            value: '50-59.9',
            checked: false
          },
          {
            score: '1',
            value: '46-49.9',
            checked: false
          },
          {
            score: '0',
            value: '30-45.9',
            checked: false
          },
          {
            score: '1',
            value: '',
            checked: false
          },
          {
            score: '2',
            value: '20-29.9',
            checked: false
          },
          {
            score: '3',
            value: '',
            checked: false
          },
          {
            score: '4',
            value: '<20',
            checked: false
          },
        ]
      }
      ,
      {
        name: '11.WBC（*1000）',
        type: 'WBC',
        checkIndex: null, // 保存选中的值 或者下标
        intervalList: [
          {
            score: '4',
            value: '>=40',
            checked: false
          },
          {
            score: '3',
            value: '',
            checked: false
          },
          {
            score: '2',
            value: '20-39.9',
            checked: false
          },
          {
            score: '1',
            value: '15-19.9',
            checked: false
          },
          {
            score: '0',
            value: '3-14.9',
            checked: false
          },
          {
            score: '1',
            value: '',
            checked: false
          },
          {
            score: '2',
            value: '1-2.9',
            checked: false
          },
          {
            score: '3',
            value: '',
            checked: false
          },
          {
            score: '4',
            value: '<1',
            checked: false
          },
        ]
      }
    ],
  },
  GCSscoreList: {
    row: {
      name: 'C.GCS评分',
      scope: '分',
      scoreList: ['6', '5', '4', '3', '2', '1'], // 分数
    },
    data: [
      {
        name: '1. 睁眼反应',
        type: 'eyes',
        intervalList: [
          {
            score: '6',
            value: '',
            checked: false
          },
          {
            score: '5',
            value: '',
            checked: false
          },
          {
            score: '4',
            value: '自动睁眼',
            checked: false
          },
          {
            score: '3',
            value: '呼唤睁眼',
            checked: false
          },
          {
            score: '2',
            value: '刺疼睁眼',
            checked: false
          },
          {
            score: '1',
            value: '不能睁眼',
            checked: false
          },
        ]
      },
      {
        name: '2. 语言反应',
        type: 'language',
        intervalList: [
          {
            score: '6',
            value: '',
            checked: false
          },
          {
            score: '5',
            value: '回答切题',
            checked: false
          },
          {
            score: '4',
            value: '回答不切题',
            checked: false
          },
          {
            score: '3',
            value: '答非所问',
            checked: false
          },
          {
            score: '2',
            value: '只能发音',
            checked: false
          },
          {
            score: '1',
            value: '不能言语',
            checked: false
          },
        ]
      },
      {
        name: '3. 运动反应',
        type: 'motion',
        intervalList: [
          {
            score: '6',
            value: '按吩咐动作',
            checked: false
          },
          {
            score: '5',
            value: '刺疼能定位',
            checked: false
          },
          {
            score: '4',
            value: '刺疼能躲避',
            checked: false
          },
          {
            score: '3',
            value: '刺疼肢体屈曲',
            checked: false
          },
          {
            score: '2',
            value: '刺疼肢体伸展',
            checked: false
          },
          {
            score: '1',
            value: '不能活动',
            checked: false
          },
        ]
      },
    ]
  },
  describeList: [
    {
      name: '1.数据采集应为病人入ICU或抢救开始后24小时内最差值，并注明具体评分时间。'
    },
    {
      name: '2.B项中“慢性病”指住院前患者具有严重器官功能障碍或免疫功能受损病史，判定标准如下，具备一项即可：',
      children: [
        {
          name: '①肝脏：'
        },
        {
          name: '2）免疫缺陷'
        },
        {
          name: '3）严重器官损伤'
        },
        {
          name: '4）严重器官损伤'
        },
        {
          name: '5）严重器官损伤'
        },
        {
          name: '6）严重器官损伤'
        }
      ]

    }],

  discrepancy: [
    {
      score: '入科',
      value: '入科',
      checked: false
    },
    {
      score: '出科',
      value: '出科',
      checked: false
    }
  ],
  // 总分
  Allscore: {
    Ascore: '',  // A的分数
    Bscore: '',  // B的分数
  },
  submitData: {

  },
  timeVlue: '',
  id: '',
  patientInfo: {},

})
const {
  physiologyList,
  describeList,
  ageList,
  healthList,
  Allscore,
  GCSscoreList,
  discrepancy,
  submitData,
  timeVlue,
  patientInfo,
  id
} = toRefs(state);


onMounted(() => {

  getDocPatientInfoFn()
  getDocDataFn()
  return
  const route = useRoute();
  // 访问查询参数
  if (route.query.id) {
    id.value = route.query.id
    getDocPatientInfoFn(route.query.id)
    getDocDataFn(route.query.id)
  }
})
// 获取患者基本信息
const getDocPatientInfoFn = async () => {
  let res = await getPatientInfoAPI(1546)
  if (res) {
    patientInfo.value = res[0]
  }
}
// 获取患者评分数据
const getDocDataFn = async (id) => {
  let res = await getDocDataAPI(1546)
  if (res.endsWith(')')) {
    res = JSON.parse(res.slice(0, -1))
    if (res.submitData.ageList) {
      ageList.value[res.submitData.ageList.index].checked = true
    }
    if (res.submitData.healthList) {
      healthList.value[res.submitData.healthList.index].checked = true
    }
    Allscore.value.Ascore = res.Ascore
    Allscore.value.Bscore = res.Bscore

    updateCheckedStatus(res.submitData, physiologyList.value.data)
    // updateCheckedStatus(JSON.parse(res), GCSscoreList.value)

  }
}
// 处理匹配和更新checked属性的函数
const updateCheckedStatus = (submitData, physiologyList) => {
  console.log(submitData, 'submitData')
  console.log(physiologyList, 'physiologyList')
  physiologyList.forEach((item) => {
    console.log(item, 'item.name')
    // if(item.type)
  })


  return
  for (const key in givenObj.submitData) {
    if (givenObj.submitData.hasOwnProperty(key)) {
      const givenItem = givenObj.submitData


      // 在physiologyList.data中查找匹配的type
      for (let i = 0; i < physiologyList.data.length; i++) {
        const item = physiologyList.data[i];

        // 假设我们想要根据key（这里是WBC，但实际上应该根据type匹配）来找到对应的项
        // 由于这里的示例不匹配，我们直接跳过这个条件判断，只用于演示如何更新checked
        // 在实际应用中，你应该根据实际的匹配逻辑来更新checked
        /*
        if (item.type === key) { // 这里应该是 if (item.type === '某个实际的匹配键') {
        */
        // 查找intervalList中与givenItem.value匹配的项，并更新checked
        for (let j = 0; j < item.intervalList.length; j++) {
          const interval = item.intervalList[j];
          // 注意：这里的比较可能需要根据实际情况调整，比如使用正则表达式来匹配值范围
          if (interval.score === givenItem.score /* && interval.value的某种匹配逻辑 */) {
            interval.checked = true;
            // 如果需要，也可以设置checkIndex
            // item.checkIndex = j; // 但在这个例子中我们不需要它
            break; // 假设每个score只对应一个interval，找到后就退出循环
          }
        }
        //}
      }
    }
  }
}


// 保存患者基本信息
const saveDocPatientInfoFn = async (obj) => {
  console.log(JSON.stringify(obj), 'JSON.stringify(obj)')
  let res = await saveDocPatientInfoAPI(1546, JSON.stringify(obj))
  if (res == 1) {
    getDocDataFn()
  }

}

// 计算D分数
const DStore = computed(() => {
  return sumCheckedScores(physiologyList.value.data)
})

// 计算C分数
const CStore = computed(() => {
  return sumCheckedScores(GCSscoreList.value.data)
})


// 计算总分
const total = computed(() => {
  return DStore.value + CStore.value + Number(Allscore.value.Ascore) + Number(Allscore.value.Bscore)
})

// 汇总分数的方法
const sumCheckedScores = (dataArray) => {
  return dataArray?.reduce((totalScores, item) => {
    // 对每个 item 的 intervalList 应用 reduce 方法
    const checkedScores = item.intervalList.reduce((scoresSum, interval) => {
      // 如果 checked 为 true，则累加 score
      if (interval.checked) {
        return scoresSum + parseInt(interval.score, 10); // 确保将 score 转换为数字进行累加
      }
      return scoresSum;
    }, 0); // 初始值为 0
    // 将当前 item 的 checked scores 加到总和中
    return totalScores + checkedScores;
  }, 0); // 初始总分也为 0
}


// 计算 A B 的分数
const countAscoreFn = (item, type) => {
  if (type == "A") {
    ageList.value.forEach(v => {
      if (item.value !== v.value) {
        v.checked = false;
      }
    })
    Allscore.value.Ascore = Number(item.score);
  } else {
    healthList.value.forEach(v => {
      if (item.value !== v.value) {
        v.checked = false;
      }
    })
    Allscore.value.Bscore = Number(item.score);
  }
}

// 计算 C D 的分数
const handleCheckChange = (child, childIndex, parentData) => {
  parentData.forEach(v => {
    if (child.value !== v.value) {
      v.checked = false;
    }
  })
}
// 出入科点击
const discrepancyChange = (index) => {
  discrepancy.value.forEach((item, indexOne) => {
    if (index != indexOne) {
      item.checked = false
    }
  })
}

const baseScores = computed(() => physiologyList.value.row.scoreList);


watchEffect(() => {
  console.log("watchEffect DscoreDscore", physiologyList.value);
})

// 打印
const printFn = () => {
  // 选择要捕获的DOM元素
  const element = document.querySelector('#container');
  // element.style.borderRight = '2px solid black'
  // element.style.border = 'none'


  html2canvas(element, {
    allowTaint: true,
    taintTest: false,
    useCORS: true,
    dpi: 800,
    scale: 3,
  }).then(canvas => {
    // 将canvas转换为Base64图像数据
    const imgData = canvas.toDataURL('image/png');
    printJS({
      printable: imgData,
      type: "image",
      targetStyles: ["*"],
      style: `
        body{
        margin:0;
        padding:0;
        }
      `,
      scanStyles: false
    })
  })
}
// 清空
const clearFn = () => {
  clearData(ageList.value)
  clearData(healthList.value)
  clearData(discrepancy.value)
  clearData(physiologyList.value.data) // 这个
  clearData(GCSscoreList.value.data)  // 和这个
}

const clearData = (arr) => {
  arr.forEach((item) => {
    if (item.intervalList) {
      item.intervalList.forEach((interval) => {
        interval.checked = false;
      })
    } else {
      item.checked = false;
    }
  });
}

// 保存
const handleSubmit = () => {
  physiologyList.value.data.forEach(item => {
    item.intervalList.forEach((interval, index) => {
      if (interval.checked) {
        submitData.value[item.type] = {
          value: interval.value,
          score: interval.score,
          index: index
        };
      }
    });
  });

  GCSscoreList.value.data.forEach(item => {
    item.intervalList.forEach((interval, index) => {
      if (interval.checked) {
        submitData.value[item.type] = {
          value: interval.value,
          score: interval.score,
          index: index
        };
      }
    });
  });

  ageList.value.forEach((item, index) => {
    if (item.checked) {
      submitData.value.ageList = {
        value: item.value,
        score: item.score,
        index: index
      }
    }
  })
  healthList.value.forEach((item, index) => {
    if (item.checked) {
      submitData.value.healthList = {
        value: item.value,
        score: item.score,
        index: index
      }
    }
  })

  discrepancy.value.forEach((item, index) => {
    if (item.checked) {
      submitData.value.discrepancy = {
        value: item.value,
        score: item.score,
        index: index
      }
    }
  })

  let obj = {
    Ascore: Allscore.value.Ascore,
    Bscore: Allscore.value.Bscore,
    CStore: CStore.value,
    DStore: DStore.value,
    total: total.value,
    timeVlue: timeVlue.value,
    submitData: submitData.value
  }
  console.log(obj, '点击了提交')
  saveDocPatientInfoFn(obj)
}

</script>

<style scoped lang="scss">
.table {
  color: black;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  .print {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    margin: 20px 800px 20px 0;
  }

  .container {
    padding: 40px;
    flex: 1;
    // border: 1px solid black;

    .baseInfo {
      display: flex;
      justify-content: space-around;
      margin: 20px 0;

    }

    .footer {
      display: flex;
      flex-direction: column;
      align-items: flex-start;

      .fraction_info {
        display: flex;
        justify-content: space-between;
        width: 100%;
        margin: 20px 0;
      }

      .graders {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        width: 100%;
      }

      .describe {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;

        word-break:break-all .describe_title {
          flex: 1;
        }

        .describe_content {
          display: flex;
          flex-direction: column;
          align-items: flex-start;
        }
      }


    }
  }

  .operate {
    margin: 20px 0 60px 0;
    display: flex;
    justify-content: center;
    width: 100%;
  }
}

.bordered-table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 20px;
}

.bordered-table th,
.bordered-table td {
  border: 1px solid black;
}

.dflex {
  display: flex;
  justify-content: space-around;
}

.age {
  display: flex;
  align-items: center;
}

.el-checkbox {
  color: black;
}

:deep(.el-input__inner) {
  color: black !important;
}

td {
  word-break: break-all
}
</style>
<style>
@media print {
  body {
    margin: 0;
    padding: 0;
  }

  @page {
    margin: 0;
  }
}
</style>